<!--
 * @Description: 节点完成(节点维护改名)
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-11-17 15:05:06
 * @LastEditTime: 2023-06-30 11:32:47
 * @FilePath: \cscec-pms-admin\src\views\construction\constructionSchedule\components\NodeMaintain.vue
-->
<template>
  <BaseModal
    :visible="visible"
    :title="apiCode  === 0 ? '节点开始/完成' : '节点维护'"
    :width="1200"
    destroy-on-close
    :wrap-class-name="'node-maintain'"
    @cancel="handleModalCancel()"
  >
    <div class="node-maintain">
      <NodeMaintainPage
        ref="nodeMaintainPage"
        :source="data"
        :loading.sync="loading"
        :submiting.sync="submiting"
        :api-code="apiCode"
        @handleModalCancel="handleModalCancel"
      />
    </div>
    <template slot="footer">
      <a-button @click="handleModalCancel()">
        取消
      </a-button>
      <a-button
        v-if="data.type === 'detail' && (data.nodeStatus === 4 || data.nodeStatus === 5)"
        type="primary"
        :disabled="loading"
        :loading="submiting"
        @click="handleSubmit"
      >
        提交附件
      </a-button>
      <a-button
        v-if="data.type !== 'detail' && (data.nodeStatus === 0 || data.nodeStatus === 1|| data.nodeStatus === 3)"
        type="primary"
        :disabled="loading"
        :loading="submiting"
        @click="handleSubmit"
      >
        {{ data.type === 'detail'?'提交附件':'提交审批' }}
      </a-button>
    </template>
  </BaseModal>
</template>
<script>
import BaseModal from '@/components/BaseModal'
import NodeMaintainPage from './NodeMaintainPage'
export default {
  name: 'NodeMaintain',
  props: {
    // 隐藏显示
    visible: {
      type: Boolean,
      require: true
    },
    // 节点信息
    data: {
      type: Object,
      require: true
    },
    // 接口代码 0：总计划，2：竣工收尾计划
    apiCode: {
      type: Number,
      default: 0
    }
  },
  components: {
    BaseModal,
    NodeMaintainPage
  },
  data() {
    return {
      loading: false,
      submiting: false
    }
  },
  watch: {
    visible: {
      handler(v) {
        if (v) {
          this.$nextTick(() => {
            this.$refs.nodeMaintainPage.getData()
          })
        } else {
          this.$refs.nodeMaintainPage.form = {}
          this.$refs.nodeMaintainPage.form1 = {}
        }
      }
    }
  },
  methods: {
    /**
     * @description: 关闭模态框
     * @param {boolean} 是否需要刷新
     * @return {void}
     */
    handleModalCancel(refresh = false) {
      this.$refs.nodeMaintainPage.handleclose()
      // this.visible = false
      this.$emit('update:visible', false)
      if (refresh) {
        this.$emit('refresh', true)
      }
    },
    /**
     * @description: 提交审批
     * @param {void}
     * @return {void}
     */
    handleSubmit() {
      this.$refs.nodeMaintainPage.handleSubmit()
    }
  }
}
</script>
<style lang="less" scoped>
.node-maintain {
  height: calc(var(--heightVh) * 0.6);
  overflow-y: auto;
  padding-right: 10px;
}
</style>
